package com.example.userservice.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.userservice.model.User;
import com.example.userservice.model.vo.UserVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    
    /**
     * 查询所有用户列表
     */
    @Select("select user_id, username, email, phone, gmt_create " +
            "from users " +
            "order by gmt_create desc ")
    List<UserVO> selectUserListWithRole();

    /**
     * 根据用户ID查询单个用户信息
     */
    @Select("select user_id, username, email, phone, gmt_create " +
            "from users " +
            "where user_id = #{userId} " +
            "order by gmt_create desc ")
    List<UserVO> selectUserById(@Param("userId") Long userId);
}
